// src/router/index.js
import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import CampusBinhai from '../views/CampusBinhai.vue'
import CampusChashan from '../views/CampusChashan.vue'
import CampusYueqing from '../views/CampusYueqing.vue'
import StudentSystem from '../views/StudentSystem.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'CampusBinhai',
    component: CampusBinhai
  },
  {
    path: '/campusChashan',
    name: 'CampusChashan',
    component: CampusChashan
  },
  {
    path: '/campusYueqing',
    name: 'CampusYueqing',
    component: CampusYueqing
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/studentSystem',
    name: 'StudentSystem',
    component: StudentSystem,
    beforeEnter: (to, from, next) => {
      const isAuthenticated = false; 
      if (!isAuthenticated) {
        next('/login');
      } else {
        next();
      }
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
